{% extends 'base.html' %}
{% load static %}
{% block title %}用例执行记录{% endblock %}
{% block content %}

<div class="table-responsive">
    <table class="table table-striped">
        <thead>
        <tr>
            <th width="4%">id</th>
            <th width="4%">名称</th>
            <th width="20%">请求数据</th>
            <th width="20%">执行返回结果</th>
            <th width="5%">操作</th>
            <th>断言内容</th>
            <th width="5%">执行结果</th>
            <th width="5%">异常信息</th>
            <th width="10%">请求后提取变量</th>
            <th width="8%">开始时间</th>
            <th width="8%">执行耗时(ms)</th>
        </tr>
        </thead>
        <tbody>

        {% for testrecord in test_case_execute_records %}
        <tr>
            <td>{{ testrecord.id }}</td>
            <td><a href="{% url 'test_case_detail' testrecord.belong_test_case.id%}" target="_blank">{{ testrecord.belong_test_case.case_name }}</a></td>
            <td>{{ testrecord.request_data }}</td>
            <td>{{ testrecord.response_data }}</td>
            <td><a href="{% url 'case_result_diff' testrecord.id %}" target="_blank">对比差异</a></td>
            <td>{{ testrecord.belong_test_case.assert_key }}</td>

            {% ifequal testrecord.execute_result '成功' %}
            <td bgcolor='green'>{{ testrecord.execute_result}}</td>
            {% else %}
            <td bgcolor='red'>{{ testrecord.execute_result}}</td>
            {% endifequal %}

            {% if testrecord.exception_info %}
            <td><a href="{% url 'show_exception' testrecord.id %}" target="_blank">显示异常信息</a></td>
            {% else %}
            <td>无</td>
            {% endif %}

            <td>{{ testrecord.extract_var }}</td>
            <td>{{ testrecord.execute_start_time }}</td>
            <td>{{ testrecord.execute_total_time }}</td>
        </tr>
        {% endfor %}

        </tbody>
    </table>

    {# 实现分页标签的代码 #}
    {# 这里使用 bootstrap 渲染页面 #}
    <div id="pages" class="text-center">
        <nav>
            <ul class="pagination">
                <li class="step-links">
                    {% if test_case_execute_records.has_previous %}
                    <a class='active' href="?page={{ test_case_execute_records.previous_page_number }}">上一页</a>
                    {% endif %}

                    <span class="current">
                    第 {{ test_case_execute_records.number }} 页 / 共 {{ test_case_execute_records.paginator.num_pages }} 页</span>

                    {% if test_case_execute_records.has_next %}
                    <a class='active' href="?page={{ test_case_execute_records.next_page_number }}">下一页</a>
                    {% endif %}
                </li>
            </ul>
        </nav>
    </div>
</div>
{% endblock %}
